﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.PlanningManagement;
using Digitalmes.Model.FactoryManagement;
using Digitalmes.Model.ProcessManagement;
using Digitalmes.Model.ProductManagement;

namespace Digitalmes.Model.PlanningManagement
{
    /// <summary>
    /// ProductionTask
    /// </summary>
	[Table("ProductionTask")]

    [Display(Name = "_Model.ProductionTask")]
    public class ProductionTask : BasePoco,IPersistPoco,ITenant
    {
        [Display(Name = "_Model._ProductionTask._ProductId")]
        [Comment("产品")]
        public long? ProductId { get; set; }

        public Product Product { get; set; }

        [Display(Name = "_Model._ProductionTask._ProductName")]
        [Comment("产品名称")]
        public string ProductName { get; set; }
        [Display(Name = "_Model._ProductionTask._Wo")]
        [Comment("工单")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string Wo { get; set; }
        [Display(Name = "_Model._ProductionTask._LineId")]
        [Comment("产线")]
        public long? LineId { get; set; }

        public ProductionLine Line { get; set; }    

        [Display(Name = "_Model._ProductionTask._LineCode")]
        [Comment("产线编码")]
        public string LineCode { get; set; }
        [Display(Name = "_Model._ProductionTask._ShiftId")]
        [Comment("班次")]
        public long? ShiftId { get; set; }

        public LineShift Shift { get; set; }    

        [Display(Name = "_Model._ProductionTask._ShiftCode")]
        [Comment("班次代号")]
        public string ShiftCode { get; set; }
        [Display(Name = "_Model._ProductionTask._ProductCode")]
        [Comment("产品名称")]
        public string ProductCode { get; set; }
        [Display(Name = "_Model._ProductionTask._OpId")]
        [Comment("工位")]
        public long? OpId { get; set; }

        public ProcessRouteItem Op { get; set; }    

        [Display(Name = "_Model._ProductionTask._OpCode")]
        [Comment("工位号")]
        public string OpCode { get; set; }
        [Display(Name = "_Model._ProductionTask._ProductionBatch")]
        [Comment("生产批次")]
        public string ProductionBatch { get; set; }
        [Display(Name = "_Model._ProductionTask._ProdOrder")]
        [Comment("关联订单")]
        public ProductionOrder ProdOrder { get; set; }
        [Display(Name = "_Model._ProductionTask._ProdOrder")]
        [Comment("关联订单")]
        public long? ProdOrderId { get; set; }
        [Display(Name = "_Model._ProductionTask._TaskStatus")]
        [Comment("任务状态")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public WoStatusEnum? TaskStatus { get; set; }
        [Display(Name = "_Model._ProductionTask._OnlineQty")]
        [Comment("上线数量")]
        [Precision(18,2)]
        [Required(ErrorMessage = "Validate.{0}required")]
        public decimal? OnlineQty { get; set; }
        [Display(Name = "_Model._ProductionTask._PlanQty")]
        [Comment("计划数量")]
        [Precision(18,2)]
        [Required(ErrorMessage = "Validate.{0}required")]
        public decimal? PlanQty { get; set; }
        [Display(Name = "_Model._ProductionTask._QualifiedQty")]
        [Comment("合格数量")]
        [Precision(18,2)]
        [Required(ErrorMessage = "Validate.{0}required")]
        public decimal? QualifiedQty { get; set; }
        [Display(Name = "_Model._ProductionTask._UnqualifiedQty")]
        [Comment("不合格数量")]
        [Precision(18,2)]
        [Required(ErrorMessage = "Validate.{0}required")]
        public decimal? UnqualifiedQty { get; set; }
        [Display(Name = "_Model._ProductionTask._ScrapQty")]
        [Comment("报废数量")]
        [Precision(18,2)]
        [Required(ErrorMessage = "Validate.{0}required")]
        public decimal? ScrapQty { get; set; }
        [Display(Name = "_Model._ProductionTask._CompletedQty")]
        [Comment("完工数量")]
        [Precision(18,2)]
        [Required(ErrorMessage = "Validate.{0}required")]
        public decimal? CompletedQty { get; set; }
        [Key]
        [Display(Name = "_Model._ProductionTask._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }
        [Display(Name = "_Model._ProductionTask._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
